<?php

namespace App\Http\Controllers;

use App\Models\GrAddress;
use App\service\JwtService;
use App\service\ReturnService;
use Illuminate\Http\Request;

class ShoppingCart extends Controller
{
    //购物车获取用户默认地址
    public function cartAddress(Request $request)
    {
        $token = $request->get('token');
        $userId = JwtService::decodeToken($token);
        $id = $userId->data->id;
        $data = GrAddress::where('uid', $id)->where('is_default',1)->first();
        if (empty($data)){
            return ReturnService::failedReturn(300, '地址为空');
        }
        return ReturnService::successReturn(200, '查询成功', $data);

    }
}
